package com.corpdata.app;

import com.corpdata.common.api.keyfree.GenerateUtil;
import com.corpdata.common.utils.OkHttpUtil;
import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;

import java.util.HashMap;
import java.util.Map;

/**
 * @auther: Zealon
 * @Date: 2018-06-22 12:36
 */
public class App {

    public static void main(String[] args){

        //testFreekey();
        openDoor();

    }

    //测试用例
    public static void testFreekey(){

        String accessToken = GenerateUtil.generate(3,900,"528");

        String url = "http://www.key1.cn/reformer/member/api/member/queryByPhone";

        Map<String,String> params = new HashMap<String,String>();
        String data = "{\"cmpId\":1303,\"proId\":528,\"phone\":\"15210865233\"}";

        params.put("data",data);
        params.put("accessToken",accessToken);

        String result = OkHttpUtil.post(url,params);
        System.out.println("请求参数：");
        System.out.println("data："+data);
        System.out.println("accessToken："+accessToken+"\n------------------------------------------------------");
        System.out.println("响应："+result);
    }

    //远程开门用例
    public static void openDoor(){
        String url = "http://www.key1.cn/reformer/member/api/remote/openDoor";
        Map<String,String> params = new HashMap<String,String>();
        String data = "{\"cmpId\":1303,\"proId\":528,\"mac\":\"D47C5FFDB659\"}";
        String accessToken = GenerateUtil.generate(3,900,"528");
        params.put("data",data);
        params.put("accessToken",accessToken);
        String result = OkHttpUtil.post(url,params);
        System.out.println(result);
    }
}
